import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class WriteFile {

	private String output_filename = "";
	FileWriter output;
	BufferedWriter out;
	ArrayList<String> linkCollectionUnique = new ArrayList<String>();

	public WriteFile() {
		this.output_filename = "";
	}

	public WriteFile(String str, String output_filename) throws IOException {
		this.output_filename = output_filename;
		output = new FileWriter(this.output_filename,true);
		out = new BufferedWriter(output);
		writeLogProgress(str);
	}

	public void writeLogProgress(String str) throws IOException {
			out.write(str);	
			out.newLine();
			out.close();
	}

	public WriteFile(ArrayList<String> linkCollectionUnique,
			String output_filename) throws IOException {
		this.output_filename = output_filename;
		this.linkCollectionUnique = linkCollectionUnique;

		output = new FileWriter(this.output_filename);
		out = new BufferedWriter(output);
		writeOutput();
	}

	public void writeOutput() throws IOException {
		String str = "";
		for (String ele : linkCollectionUnique) {
			if (ele.length() != 0) {
				str = ele + ";";
				out.write(str);
				out.newLine();
			}
		}
		out.close();
		Util.writeLog("\t - Write to file " + output_filename);
	}

}
